package br.ufpe.cin.camid.core.objects;




public class ManagedObjectHandler 
{
	private String id;
	
	private Object object;
	
	private AcquireStrategy acquireStrategy;

	private InvocationTask task;

	public ManagedObjectHandler(String id, Object object, AcquireStrategy acquireStrategy)
	{
		this.id = id;
		this.object = object;
		this.acquireStrategy = acquireStrategy;
		this.task = new InvocationTask();
	}
	
	public String getId() {
		return id;
	}

	public Object getObject() {
		return object;
	}

	public Object dispatchInvocation(String method, Object[] parameters) 
	{
		Object result = task.call(object, method, parameters);
		return result;
	}

	public Class<?> getManagedObjectType() {
		
		return object.getClass();
	}

	public void acquire()
	{
		this.acquireStrategy.acquire();
	}
	
	public void release()
	{
		this.acquireStrategy.release();
	}
	
	
}
